<template>
	<view>
		<view class="box">
			<view style="color: orange;font-size: 24px;">{{postData.title}}</view>
			<view style="margin-bottom: 10px;margin-top: 10px;font-size: 16px;color: black;">
				<view style="display: flex;margin-top: 10px;">
					<image src="../../static/icons/用户.png" style="width: 40rpx;" mode="widthFix">
					</image>
					<view style="margin-top: 5px;margin-right: 10px;">{{postData.userName}}</view>
					<image src="../../static/icons/眼睛.png" style="width: 40rpx;margin-top: 3px;" mode="widthFix">
					</image>
					<view style="margin-top: 5px;margin-right: 10px;">{{postData.lookNum}}</view>
					<image src="../../static/icons/点赞.png" style="width: 40rpx;margin-top: 3px;" mode="widthFix">
					</image>
					<view style="margin-top: 5px;margin-right: 10px;">{{postData.clickNum}}</view>
					<image src="../../static/icons/收藏.png" style="width: 40rpx;margin-top: 3px;" mode="widthFix">
					</image>
					<view style="margin-top: 5px;margin-right: 10px;">{{postData.collectNum}}</view>
				</view>
				<view style="display: flex;gap: 10px;">
					<image src="../../static/icons/时间.png" style="width: 40rpx;margin-top: 3px;" mode="widthFix">
					</image>
					<view style="margin-top: 5px;margin-right: 10px;">{{postData.postTime }}</view>
				</view>
			</view>
			<rich-text :nodes="postData.content"></rich-text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				postId: '',
				postData: {},
				typeId: '',

			}
		},
		onShow() {
			this.loadPost()
			this.updateCount()
		},
		onLoad(option) {
			this.postId = parseInt(option.postId); // 转换为整数
			this.typeId = parseInt(option.typeId); // 转换为整数
		},
		methods: {
			// loadFrontPost() {
			// 	this.$request.get(`/post/selectFrontPost/${this.typeId}`).then(res => {
			// 		if (res.code === '200') {
			// 			this.frontPostData = res.data;
			// 		} else {
			// 			this.$message.error(res.msg);
			// 		}
			// 	});
			// },
			updateCount() {
				this.$request.put('/post/updateCount/' + this.postId).then(res => {
					this.loadPost()
				})
			},
			loadPost() {
				this.$request.get(`/post/selectById/${this.postId}`).then(res => {
					if (res.code === '200') {
						this.postData = res.data;
					} else {
						this.$message.error(res.msg);
					}
				});
			},
		}
	}
</script>

<style>

</style>